
using System;
using System.Web;
using System.Web.Security;

using Grr.Models;
using Castle.MonoRail.Framework;
using Castle.MonoRail.Framework.Views.Aspx;

namespace Grr.Web
{
    public abstract class GrurrahViewPage : PageBase
    {
        protected abstract string TabName
        {
            get;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            Gaia.WebWidgets.Manager.Instance.CallbackURL = Request.RawUrl;
            if (!IsPostBack)
            {
                SetTab();
                if (ControllerContext != null)
                    SetProperties();
            }
        }

        protected virtual void SetProperties()
        {
        }

        public virtual void OnUserLoggedIn(MembershipUser user)
        {
        }

        public virtual void OnUserLoggedOut()
        {
        }

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            base.Render(new FormRewriterTextWriter (writer));
        }

        private void SetTab()
        {
            ITabContainer tabs = (ITabContainer)Master;
            if (tabs != null)
                tabs.SetCurrentTab(TabName);
        }

    }
}
